/* 
 * @author 朱家进
 * @version 1.4
 * ���ܣ��û�����
 * 2007-04-11
 */

package com.zjht.gmcc.servlet.sys;

import java.io.PrintWriter;
import java.sql.PreparedStatement;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zjht.gmcc.bean.BaseServlet;
import com.zjht.gmcc.bean.util.MyJDBC;


public class UpdateDepartment extends BaseServlet {

	private static final long serialVersionUID = 2698843179967029514L;


	public boolean process(HttpServletRequest request, HttpServletResponse response,HttpSession session, PrintWriter out, MyJDBC myJDBC,  String menu)throws Exception {

		int i_flag = 0;

		// ===============
		/*
		 * String s_zzlb = request.getParameter("zzlbid"); String flag = request.getParameter("flag");
		 */

		String oldDeptid = request.getParameter("oldDepart");
		String newDepart = request.getParameter("newDepart");

		// String url ="/sys/orga/departmentadd.jsp?zzlb="+s_zzlb;
		/*
		 * String s_destination_cg ="/sys/depart/departmentadd.jsp?zzlb="+s_zzlb+"&flag="+flag; String s_destination_top
		 * ="/sys/depart/depart.jsp?zzlb="+s_zzlb+"&flag="+flag;
		 */

		String s_sql = null;
		PreparedStatement ps = null;
		// ResultSet rs = null;

		s_sql = "update department set deptname = ? where deptid =?";
		ps = myJDBC.prepareStatement(s_sql);
		ps.setString(1, newDepart);
		ps.setString(2, oldDeptid);
		i_flag = ps.executeUpdate();

		s_sql = null;
		ps.close();
		ps = null;
		String act = "部门修改";
		if (i_flag > 0) {
			alertOK(out,act + "成功", "window.returnValue='3';window.close();");
		} else {
			errAlert(request, out, menu, act + "失败");
		}
		return i_flag > 0;
	}
}
